<template>
	<view>
		<!-- <view style="display: flex;justify-content: space-around;height: 300upx;background-color: #fff;margin-top: 20upx;">
			<view style="margin-top: 50upx;">
				<image style="width: 170upx;height: 150upx;" src="../../../static/tzzlogo.png" mode=""></image>
			</view>
			<view style="height: 200upx;">
				<view style="margin-top: 75upx;">
					当时算力 <text style="color: #D5832D;margin-left: 15upx;"> {{wheel}}轮</text>
				</view>
				<view style="font-size: 32upx;color: #D5832D;font-weight: 600;text-align: center;">
					{{zichan_power}}
				</view>
			</view>
			<view style="height: 200upx;">
				<view style="margin-top: 50upx;">
					<text>剩余兑换资产数量</text>
					<view>{{s_exchange}}</view>
				</view>
				<view>
					<text>已释放</text>
					<view>{{bz_release}}</view>
				</view>
			</view>
		</view> -->
		<view class="" style="height: 100upx;line-height: 100upx;display: flex;background-color: #fff;padding-bottom: 50upx;margin-top: 20upx;">
			<view @click="tobuyorder" style="height: 80upx;line-height: 80upx;background-color: #05052B;margin-top: 30upx;width: 40%;margin-left: 5%;text-align: center;color: #fff;font-size: 32upx;border-radius: 20upx;">
				我的易通值订单
			</view>
			<!-- <view @click="togetbuy" style="height: 80upx;line-height: 80upx;background-color: #FE7273;margin-top: 20upx;width: 40%;margin-left: 10%;text-align: center;color: #fff;font-size: 32upx;border-radius: 20upx;">
				兑换资产
			</view> -->
		</view>
		<view class="container" style="margin-top: 30upx;">
			<!-- <view class="all_add">累计奖励 + {{topres}} 元</view> -->
			<!-- 带上拉加载的数据列表 -->
			<view class="big-loading-text loading-text" style="height: 80upx;line-height: 80upx;">
				<text>市场挂单</text>
				<!-- <text>数量</text>
				<text>当时算力</text> -->
			</view>
			<!-- 数据列表 -->
			<scroll-view scroll-y="true" style="height: 900upx;">
				<view @click="tobuy(item)" v-for="(item,key) in list" :key="key" style="height: 170upx;box-shadow: 2upx 2upx 10upx #CCCCCC;margin: 20upx;padding: 30upx;">
					<view class="" style="display: flex;">
						<text>挂卖时间:{{item.time}}</text>
						<!-- <text>{{item.id}}</text> -->
						<!-- <text>交易中:{{item.dnum}}</text> -->
					</view>
					<view class="" style="display: flex;justify-content: space-between;line-height: 75upx;">
						<text>挂卖人:{{item.nick_name}}</text>
						<text>数量:{{item.znum}}</text>
						<!-- <text>算力:{{item.price}}</text> -->
					</view>
					<view class="" style="display: flex;justify-content: space-between;">
						<text>当前剩余:{{item.surplus}}</text>
						<!-- <text>{{item.id}}</text> -->
						<text>交易中:{{item.dnum}}</text>
					</view>
				</view>
			</scroll-view>
		</view>
		<!-- <view style="display: flex;background-color: #fff;width: 100%;">
			<view style="width: 45%;position: fixed;bottom: 0;left: 2%;">
				<button style="background-color: #FA3D3D;color: #fff;" @click="getbuy"  type="default">购买</button>
			</view>
			<view style="width: 45%;position: fixed;bottom: 0;right: 2%;">
				<button style="background-color: #FA3D3D;color: #fff;" type="default">卖出</button>
			</view>
		</view> -->
	</view>
</template>

<script> 
import uniLoadMore from '../../../components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				s_exchange:'',
				list:[],
				wheel:'',
				zichan_power:'',
				nzichan_power:'',
				bz:'',
				bz_release:'',
				res:[],
				openid:'',
				systemInfo:[],
				active:"active",
				index:1,
				topres:1,
				newsList:[],
				loadingText: '加载中...',
				loadingType: 0,
				contentText: {
					contentdown: '上拉显示更多',
					contentrefresh: '正在加载...',
					contentnomore: '没有更多数据了'
				},
				load: 0,
				page: 0,
				timer:{},
			}
		},
		onShow: function(e){
			this.getassets()
			this.getassets1()
		},
		onLoad: function(e) {
			// uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.getassets()
					this.getassets1()
					//页面一加载时请求一次数据`
					// uni.hideLoading()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		// 下拉刷新
		onPullDownRefresh(e) {
			this.getnewsList()
		},
		// 上拉加载
		onReachBottom(){
			if (this.timer != null) {
				clearTimeout(this.timer)
			}
			this.timer = setTimeout(()=> {
				// this.getmorenews()
			}, 1000);
		},
		methods: {
			tobuyorder(){
				uni.navigateTo({
					url:'buyorder1'
				})
			},
			togetbuy(){
				uni.navigateTo({
					url:'getbuy'
				})
			},
			tobuy(e){
				console.log(e);
				this.buy = e
				uni.setStorage({
				    key: 'buy',
				    data: this.buy,
				    success: function (res) {
				        console.log(res);
				    }
				});
				uni.navigateTo({
					url:'buydetails1'
				})
			},
			//获取资产值信息
			getassets() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.bz_exchange&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
						this.wheel = res.data.wheel
						this.zichan_power = res.data.zichan_power
						this.s_exchange = res.data.s_exchange
						this.bz_release = res.data.bz_release
						this.bz = res.data.bz
						this.nzichan_power = res.data.nzichan_power
					},
					fail: () => {},
					complete: () => {}
				});
			},
			getassets1() {
				// this.page++;//每触底一次 page +1
				// if (this.loadingType !== 0) {//loadingType!=0;直接返回
				// 	return false;
				// }
				// this.loadingType = 1;
				// uni.showNavigationBarLoading();//显示加载动画
				uni.request({
					url:this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.tzz_exchange.sale_list&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res)=> {
						console.log(res)
						this.list = res.data.result.list
						if (res.data.tzz == '') {//没有数据
							this.loadingType = 2;
							uni.hideNavigationBarLoading();//关闭加载动画
							return;
						}
						this.loadingType = 0;//将loadingType归0重置
						uni.hideNavigationBarLoading();//关闭加载动画
					}
				});
			},
			getbuy() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.bz_exchange.submit&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
						'num' : 2,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
					},
					fail: () => {},
					complete: () => {}
				});
			},
		},
	}
</script>
<style>
.container {
	background-color: #fff;
}
.loading-text {
	margin: ;
	background-color: fff;
	display: flex;
}

.loading-text text:nth-child(1) {
	padding-left: 15upx;
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 1;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(2) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 3;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(3) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 2;
	text-align: center;
	font-size: 26upx;
}
.loading-text text:nth-child(4) {
	border-bottom: 2upx solid rgb(243,243,243);
	background-color: #fff;
	flex: 5;
	text-align: center;
	font-size: 26upx;
}
.all_add {
	height: 80upx;
	text-align: center;
	line-height: 80upx;
	background-color: rgb(254,162,61);
	color: #fff;
}
.big-loading-text {
	font-weight: 550;
	border-bottom: 2upx solid rgb(243,243,243);
}
uni-page-body{height:100%;}
</style>


